#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <memory>
#include <map>
#include <set>
#include "QueryResult.h"
#include "TextQuery.h"
using namespace std;

void runQueries(ifstream &infile)
{
    TextQuery tq(infile);
    while (true)
    {
        cout << "enter word  or Q to quit ! : ";
        string s;
        // 输入单词查询 or 输入Q 退出
        if (cin >> s && (s != "q" && s != "Q"))
            myprint(cout, tq.query(s)) << endl;
        else
            break;
    }
}

int main()
{
    ifstream in("Text.txt"); // 打开文件
    if (in.is_open())
    {                   // 如果打开了
        runQueries(in); //  查询
    }
    else
    {
        cout << " open file error" << endl;
    }
    return 0;
}
